﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace day7_case2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Program program = new Program();
            double finalPrice = program.getPrice(2.3, 22, 0.75);  //输入单价，斤数，折扣
            Console.WriteLine("最终价格为{0}", finalPrice);
        }
        public double getPrice(double price, int count, double discount)
        {
            double totalPrice = price * count;  //原价
            int d = (int)(totalPrice / 20);  //有几个20元
            double totalCount = 0;  // 折扣部分的总金额
            for (int i = 0; i < d; i++)
            {
                totalCount += 20 * discount;

            }
            double lastPrice = totalPrice % 20;
            //double lastPrice = totalPrice - 20 * d;  //剩余的未打折价格
            double finalPrice = totalCount + lastPrice;
            return finalPrice;

        }
    }
}
